<?php
//注册数据
add_action('admin_init', 'register_theme_settings');
function register_theme_settings() 
{ 
    register_setting("theme_mods_freshblog","theme_mods_freshblog");
}//添加admin外观菜单
add_action('admin_menu', 'add_theme_options_menu');
function add_theme_options_menu() { 
    add_theme_page('主题设置','主题选项','edit_theme_options','theme-options', 'theme_settings_admin');
}

function theme_settings_admin() { //这里写选项页面内容
    if ( !empty($_POST) && check_admin_referer('theme_options-update') ) {
        update_option('right-click-menu', $_POST['right-click-menu']);
        echo '<div id="message" class="updated notice is-dismissible"><p>保存成功。</p></div>';
    }
    ?>
    <div class="wrap">
        <h2>主题设置</h2>
        <form action="" method="post" id="theme-options-form">
            <table class="form-table">
                <tbody>
                    <tr>
                        <th scope="row"><label for="right-click-menu">右键菜单:</label></th>
                        <td><input type="checkbox" id="right-click-menu" name="right-click-menu" <?php echo get_option('right-click-menu')?"checked":""; ?> value="yes" />开启右键菜单</td>
                    </tr>
                </tbody>
            </table>
            <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="保存更改"></p>
            <?php wp_nonce_field('theme_options-update'); ?>
        </form>
    </div>
    <?php
}
?>